#pragma once

#include "Sprite.h"
#include "Ship.h"
#include "PolylineCollisionObject.h"

#define MAX_COLLISION_POINTS 30
#define MAX_COLLISION_OBJECTS 5

class GameplayBackground {
	public:
		void Load( const char* top_bg, const char* bottom_bg );
		void Unload( );
		
		PolylineCollisionObject* AddPolylineCollisionObject();
		
		// checks for collision with the background geometry
		// and returns the normal at the position of collision
		bool CheckForCollision( const Ship &ship, CIwFVec2 *normal ) const;
		
		void Update( float dt );
		void Draw( );
		
	private:
	
		bool (*m_top_shore_collision_pre_check)( const Ship &ship );
		bool (*m_bottom_shore_collision_pre_check)( const Ship &ship );
	
		CIwFVec2 m_top_collision_points[MAX_COLLISION_POINTS];
		int m_num_top_points;
		
		CIwFVec2 m_bottom_collision_points[MAX_COLLISION_POINTS];
		int m_num_bottom_points;
		
		PolylineCollisionObject m_collision_objects[MAX_COLLISION_OBJECTS];
		int m_num_collision_objects;
		
		// the source sprites used for the background
		Sprite m_bg_top;
		CIwSVec2 m_bg_top_pos;
		
		Sprite m_bg_bottom;
		CIwSVec2 m_bg_bottom_pos;
};